//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#include <wx/wx.h>
#include "def.h"
#include "statusctrl.h"
#include "graphctrl.h"
#include "statuspanel.h"
#include <wx/statbox.h>

BEGIN_EVENT_TABLE(CStatusPanel, wxPanel)
END_EVENT_TABLE()


CStatusPanel::CStatusPanel(wxWindow* parent, wxWindowID id, const wxString& label,
		const wxPoint& pos, const wxSize& size):
			wxPanel(parent, id, pos, size)
{
	wxFlexGridSizer *sizer = new wxFlexGridSizer(1, 2, 0, 0);
	
	//Left Progress
	wxStaticBoxSizer* pBox = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY,label), wxHORIZONTAL);
	m_pStatusCtrl = new CStatusCtrl(this, wxID_ANY, wxPoint(0,0), wxSize(STATUS_CTRL_WIDTH, STATUS_CTRL_HEIGH) );
	pBox->Add( m_pStatusCtrl, 1, wxALL|wxEXPAND, DEF_CTRL_BORDER );
	
	//Right Graph
	wxStaticBoxSizer* pBoxGraph = new wxStaticBoxSizer( new wxStaticBox(this, wxID_ANY,label+wxT(" ")+_("History")), wxHORIZONTAL);
	m_pGraph = new CGraphCtrl(this, wxID_ANY, wxPoint(0,0), wxSize(GRAPH_CTRL_WIDTH, STATUS_CTRL_HEIGH) );
	pBoxGraph->Add( m_pGraph,1,wxALL|wxEXPAND, DEF_CTRL_BORDER );

	sizer->Add(pBox,	  1, wxALL|wxALIGN_CENTER|wxEXPAND, 5);
	sizer->Add(pBoxGraph, 1, wxALL|wxALIGN_CENTER|wxEXPAND, 5);
	sizer->AddGrowableCol(1, 1);
	sizer->AddGrowableRow(0, 1);
		
	SetSizer(sizer);
}

CStatusPanel::~CStatusPanel()
{
}

//IGUIBind
void CStatusPanel::SetMaxVal(unsigned int nVal)
{
	m_pStatusCtrl->SetMaxVal(nVal);
	m_pGraph->SetMaxVal(nVal);
}

unsigned int CStatusPanel::GetMaxVal()
{
	return m_pStatusCtrl->GetMaxVal();
}

void CStatusPanel::SetVal(unsigned int nVal)
{
	m_pStatusCtrl->SetVal(nVal);
	m_pGraph->SetVal(nVal);
}

void CStatusPanel::SetWarningLevel(unsigned char btVal)
{
	m_pStatusCtrl->SetWarningLevel(btVal);
}

void CStatusPanel::SetAlarmLevel(unsigned char btVal)
{
	m_pStatusCtrl->SetAlarmLevel(btVal);
}



